package com.zl.smartmall.library.po;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class OrdersInfo {

	private int id;
	private int orderId;
	private String orderNumber;// 订单号
	private int uid;
	private int deliveryWay;//自提、货到付款
	private String receiverName;// 收货人
	private String storeHouse;
	private double money;
	private long createTime;
	private int status;
	private int isReturn;//是否退换货，0否，1退货，2换货
	private int returnStatus;//退换货审核状态；0非退换货，1审核中，2审核通过处理中，3审核完成订单正常(驳回推换货),4退换货完成(货品已经发送给用
	private List<OrdersProductInfo> ordersProductInfos;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public String getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}

	public int getDeliveryWay() {
		return deliveryWay;
	}

	public void setDeliveryWay(int deliveryWay) {
		this.deliveryWay = deliveryWay;
	}

	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}

	public String getReceiverName() {
		return receiverName;
	}

	public void setReceiverName(String receiverName) {
		this.receiverName = receiverName;
	}

	public String getStoreHouse() {
		return storeHouse;
	}

	public void setStoreHouse(String storeHouse) {
		this.storeHouse = storeHouse;
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}


	public int getIsReturn() {
		return isReturn;
	}

	public void setIsReturn(int isReturn) {
		this.isReturn = isReturn;
	}

	public int getReturnStatus() {
		return returnStatus;
	}

	public void setReturnStatus(int returnStatus) {
		this.returnStatus = returnStatus;
	}

	public List<OrdersProductInfo> getOrdersProductInfos() {
		return ordersProductInfos;
	}

	public void setOrdersProductInfos(List<OrdersProductInfo> ordersProductInfos) {
		this.ordersProductInfos = ordersProductInfos;
	}

	public static List<OrdersInfo> parse(JSONArray jsonArray)
			throws JSONException {
		List<OrdersInfo> myOrdersInfos = new ArrayList<OrdersInfo>();
		for (int i = 0; i < jsonArray.length(); i++) {
			OrdersInfo orderInfo = new OrdersInfo();
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			orderInfo.setUid(jsonObject.getInt("uid"));
			orderInfo.setOrderId(jsonObject.getInt("id"));
			orderInfo.setCreateTime(jsonObject.getLong("createTime"));
			orderInfo.setOrderNumber(jsonObject.getString("sn"));
			orderInfo.setStatus(jsonObject.getInt("status"));
			orderInfo.setMoney(jsonObject.getDouble("money"));
			orderInfo.setOrdersProductInfos(OrdersProductInfo.parse(jsonObject.getJSONArray("product_info")));
			orderInfo.setReceiverName(jsonObject.getString("receiver_name"));
			orderInfo.setIsReturn(jsonObject.getInt("isReturns"));
			orderInfo.setReturnStatus(jsonObject.getInt("returnStatus"));
			orderInfo.storeHouse = jsonObject.getString("storehouse");
			orderInfo.deliveryWay = jsonObject.getInt("cpucbt");
			myOrdersInfos.add(orderInfo);

		}
		return myOrdersInfos;
	}

}
